<?php

/**
 * Product form.
 *
 * @package    test_cart
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrinePluginFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class ProductForm extends PluginProductForm
{



    public function configure()
    {
        $this->disableCSRFProtection();
        $this->setWidget('image', new sfWidgetFormInputFileEditable(
                        array('file_src'  => false,
                            'is_image'  => true,
                            'edit_mode' => !$this->isNew(),
                            'template'  => '%file% %input% '
                )));
        $this->setValidator('image', new sfValidatorFile(
                        array(
                            'mime_types' => sfConfig::get('app_image_mime_types'),
                            'required'   => $this->isNew(),
                            'path'       => sfConfig::get('sf_web_dir') . '/' . sfConfig::get('app_product_dir_images'))
                )
        )
        ;
        $this->useFields(array('title', 'description', 'price', 'image'));
        $this->getValidator('price')->setMessage('invalid', 'Allow number only');
        $this->getValidator('description')->setMessage('invalid', 'Invalid type');
        $this->validatorSchema->setOption('allow_extra_fields', true);
        $this->validatorSchema->setOption('filter_extra_fields', false);
        $this->addFormatter('CustomFormatter');
    }

    public function doUpdateObject($values)
    {
        if (!$values)
        {
            $values = $this->getValues();
        }
        parent::doUpdateObject($values);
    }

}
